﻿/*
   Copyright 2012 University of Southampton

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace uk.ac.soton.ses
{

    /*
    public enum ProcessingMode
    {
        Unknown,
        FileSystemEvent,
        DirectoryTrawl,
        CheckExistingFolders
    }
    */

    public enum HDCWatcherQueueItemState
    {
        New,
        InProgress,
        RetryRequired,
        Complete,
        CompleteWithError,
    }

    public abstract class HDCWatcherQueueItem
    {
        //Base class fields
        protected HDCFileSystemWatcher _fileSystemWatcher;
        protected string _key;
        HDCWatcherQueueItemState _queueItemState;
        
        //Properties
        public string Key
        {
            get
            {
                if (string.IsNullOrEmpty(this._key))
                {
                    this.SetKey();
                }
                return this._key;
            }
        }
        
        public HDCFileSystemWatcher FileSystemWatcher { get { return this._fileSystemWatcher; } }
        public HDCWatcherQueueItemState QueueItemState { get { return this._queueItemState; } set { this._queueItemState = value; } }

        //Abstract methods
        public abstract bool IsValid();
        protected abstract void SetKey();
        public abstract void DoWork();

        //Base class methods
        public HDCWatcherQueueItem(HDCFileSystemWatcher fileSystemWatcher)
        {
            this._queueItemState = HDCWatcherQueueItemState.New;
            this._fileSystemWatcher = fileSystemWatcher;
        }
    }
}
